<?php
/**
 * Created by PhpStorm.
 * User: xiazc01
 * Date: 2018/6/13
 * Time: 14:03
 */

namespace common\entities;

class CommonEntity extends BaseEntity{
    /**
     * @return \yii\db\connection
     */
    public static function getDb(){
        return \Yii::$app->common_log; //config/web中配置的链接
    }

    public static function getDbNowDate(){
        $db = self::getDb();
        $timestamp = $db->createCommand("SELECT UNIX_TIMESTAMP() AS `timestamp`")->queryScalar();//取数据库时间
        return date("Y-m-d H:i:s",$timestamp);
    }

    public static function getDbNowTimestamp(){
        $db = self::getDb();
        $timestamp = $db->createCommand("SELECT UNIX_TIMESTAMP() AS `timestamp`")->queryScalar();//取数据库时间
        return $timestamp;
    }


    public static function beginTransaction()
    {
        return static::getDb()->beginTransaction();
    }
}